package com.suapi.project.service.innerImpl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.suapi.project.common.ErrorCode;
import com.suapi.project.exception.BusinessException;
import com.suapi.project.service.UserInterfaceInfoService;
import com.suapi.suapicommon.model.entity.UserInterfaceInfo;
import com.suapi.suapicommon.service.InnerUserInterfaceInfoService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class InnerUserInterfaceInfoImpl implements InnerUserInterfaceInfoService {
    @Autowired
    private UserInterfaceInfoService userInterfaceInfoService;

    /**
     * 调用次数
     * @param interfaceInfoId
     * @param userId
     * @return
     */
    @Override
    public boolean invokeCount(long interfaceInfoId, long userId, int haveTimes) {
        if (interfaceInfoId <= 0 || userId <= 0){
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        return userInterfaceInfoService.invokeCount(interfaceInfoId, userId, haveTimes);
    }

    /**
     * 判断用户是否还有调用次数
     * @param interfaceInfoId
     * @param userId
     * @return
     */
//    @Override
//    public boolean isHaveTimes(long interfaceInfoId, long userId) {
//        return userInterfaceInfoService.isHaveTimes(interfaceInfoId, userId);
//    }
    @Override
    public int isHaveTimes(long interfaceInfoId, long userId) {
        return userInterfaceInfoService.isHaveTimes(interfaceInfoId, userId);
    }

    /**
     * 获取状态
     * @param interfaceInfoId
     * @param userId
     * @return
     */
    @Override
    public int getUserInterfaceInfoStatus(long interfaceInfoId, long userId) {
        return userInterfaceInfoService.getUserInterfaceInfoStatus(interfaceInfoId, userId);
    }
}
